package cn.zhoabab.study.seata.order.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.zhoabab.study.seata.order.entity.OrderEntity;
import cn.zhoabab.study.seata.order.entity.dto.OrderDTO;
import cn.zhoabab.study.seata.order.service.OrderService;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/purchase")
    public ResponseEntity purchase(@RequestBody OrderDTO orderDTO) {
        Map<String,Object> resultMap = orderService.purchase(orderDTO);
        return ResponseEntity.ok(resultMap);
    }

    @PostMapping("update")
    public void update(@RequestBody OrderEntity orderEntity){
        orderService.update(orderEntity);
    }
}
